import { defineStore } from 'pinia'
import { getHotPlaces,getCategories,getHoustList } from '@/http/modules/home'

const homeStore = defineStore("home",{
    state:()=>({
        hotPlaces:[],
        categoriesData:[],
        houseList:[],
        page:1,
        userInfo:{
            
        }
    }),
    actions:{
        async getHotCityPlace(){
            const res = await getHotPlaces();
            this.hotPlaces = res
        },
        async getCateGoriesData(){
            const res = await getCategories();
            this.categoriesData = res.data
        },
        async getHoustListData(){
            const res = await getHoustList(this.page);
            // 下拉页面最底部的时候，给列表添加更多数据
            this.houseList = [...this.houseList,...res.data]
            this.page++;

        }
        

    }
})
export default homeStore;